import { ShareSheet } from "@taroify/core";
import { useEffect, useState } from "react";

export default ({ show, change }) => {
  const [open, setOpen] = useState(show);
  useEffect(() => {
    setOpen(show);
  }, [show]);
  const handleClose = () => {
    setOpen(false);
    change(false);
  };
  return (
    <ShareSheet
      open={open}
      onSelect={() => setOpen(false)}
      onClose={handleClose}
    >
      <ShareSheet.Header title="立即分享给好友" />
      <ShareSheet.Options>
        <ShareSheet.Option icon="wechat" name="微信" />
        <ShareSheet.Option icon="wechat-moments" name="朋友圈" />
        <ShareSheet.Option icon="weibo" name="微博" />
        <ShareSheet.Option icon="qq" name="QQ" />
      </ShareSheet.Options>
      <ShareSheet.Options>
        <ShareSheet.Option icon="link" name="复制链接" />
        <ShareSheet.Option icon="poster" name="分享海报" />
        <ShareSheet.Option icon="qrcode" name="二维码" />
        <ShareSheet.Option icon="weapp-qrcode" name="小程序码" />
      </ShareSheet.Options>
      <ShareSheet.Button type="cancel">取消</ShareSheet.Button>
    </ShareSheet>
  );
};
